/********************************************************************
	created:	2009:12:9   22:14:11
	filename: 	songlistbox.h
	author:		zouyf
	describe:	
*********************************************************************/
#pragma once
#include "custommenu.h"
#include "customlistbox.h"

class FSongListBox : public CWindowImpl<FSongListBox, FCustomListBox>,
					 public COwnerDraw<FSongListBox>,
					 public FCustomMenu<FSongListBox>
{
public:
	BEGIN_MSG_MAP_EX(FSongListBox)
		MSG_WM_CREATE(OnCreate)
		MSG_WM_RBUTTONUP(OnRButtonUp)
		REFLECTED_COMMAND_CODE_HANDLER_EX(LBN_SELCHANGE, OnChange)
		COMMAND_ID_HANDLER_EX(ID_SONG_MENU_PLAY, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_SONG_MENU_RENAME, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_SONG_MENU_DELETE, OnClickMenuItem)
		COMMAND_ID_HANDLER_EX(ID_SONG_MENU_COPYTO_0, OnClickMenuItem)
		COMMAND_RANGE_HANDLER_EX(ID_SONG_MENU_COPYTO, ID_SONG_MENU_COPYTO + 15, OnClickMenuItem)
		COMMAND_RANGE_HANDLER_EX(ID_SONG_MENU_MOVETO, ID_SONG_MENU_MOVETO + 15, OnClickMenuItem)
		CHAIN_MSG_MAP_ALT(COwnerDraw<FSongListBox>, 1)
		CHAIN_MSG_MAP(COwnerDraw<FSongListBox>)
		DEFAULT_REFLECTION_HANDLER()
	END_MSG_MAP()

	int OnCreate(LPCREATESTRUCT lpCreateStruct);
	void OnClickMenuItem(UINT uNotifyCode, int nID, CWindow wndCtl);
	LRESULT OnChange(UINT uNotifyCode, int nID, CWindow wndCtl);
	void MeasureItem(LPMEASUREITEMSTRUCT lpMeasureItemStruct);
	void OnRButtonUp(UINT nFlags, CPoint point);
	void OnLButtonDblClk(UINT nFlags, CPoint point);
	void DrawItem(LPDRAWITEMSTRUCT pDrawItem);

private:
	void InnerDrawItem(int nItem);
	UINT GetIntWidth(UINT n);
	void GetBuf(UINT n, std::wstring& strBuf);
};
